<div class="tab-div">
    <div id="tabbar-div">
        <p>
            <span class="tab-front">通用信息</span>
            <span class="tab-back">商品描述</span>
            <span class="tab-back">会员价格</span>
            <span class="tab-back">商品属性</span>
            <span class="tab-back">商品相册</span>
        </p>
    </div>
    <div id="tabbody-div">
        <form enctype="multipart/form-data" action="__SELF__" method="post">
            <table width="90%" class="tab_table" id="general-table" align="center">
                <!--<tr>
                    <td class="label">分　　类：</td>
                    <td>
                        <?php $catId = I('get.cat_id'); ?>
                        <select name="cat_id">
                            <option value="">选择分类</option>
                            <?php foreach ($catData as $k => $v):
                            if($v['id'] == $catId)
                                $select = 'selected="selected"';
                            else
                                $select = '';
                            ?>
                            <option <?php echo $select; ?> value="<?php  echo $v['id']; ?>"><?php echo str_repeat('-', 8*$v['level']) . $v['cat_name']; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </td>
                </tr>-->
                <tr>
                    <td class="label">扩展分类：<input onclick="$('#cat_list').append($('#cat_list').find('li').eq(0).clone());" type="button" id="btn_add_cat" value="添加一个" /></td>
                    <td>
                        <ul id="cat_list">
                            <li>
                                <select name="ext_cat_id[]">
                                    <option value="">选择分类</option>
                                    <?php foreach($catData as $k =>$v): ?>
                                    <option value="<?php echo $v['id']; ?>"><?php echo str_repeat('-', 8*$v['level']) . $v['cat_name']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </li>
                        </ul>
                    </td>
                    <!--<span class="require-field">*</span>-->
                </tr>
                <tr>
                    <td class="label">商品名称：</td>
                    <td><input type="text" name="goods_name" value=""size="30" />
                        <span class="require-field">*</span></td>
                </tr>
                <tr>
                    <td class="label">主分类：</td>
                    <td>
                        <select name="cat_id">
                            <option value="">选择分类</option>
                            <?php foreach ($catData as $k => $v):
                                if($v['id'] == $data['cat_id'])
                                    $select = 'selected="selected"';
                                else
                                    $select = '';
                            ?>
                            <option <?php echo $select; ?> value="<?php  echo $v['id']; ?>"><?php echo str_repeat('-', 8*$v['level']) . $v['cat_name']; ?></option>
                            <?php endforeach; ?>
                        </select>
                        <span class="require-field">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">所在品牌：</td>
                    <td>
                        <?php buildSelect('brand','brand_id','id','brand_name',$data['brand_id']); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label">市场售价：</td>
                    <td>
                        <input type="text" name="market_price" value="0" size="20" />
                    </td>
                </tr>
                <tr>
                    <td class="label">本店售价：</td>
                    <td>
                        <input type="text" name="shop_price" value="0" size="20"/>
                        <span class="require-field">*</span>
                    </td>
                </tr>
                <tr>
                <td class="label">商品数量：</td>
                    <td>
                        <input type="text" name="goods_number" size="8" value=""/>
                    </td>
                </tr>
                <tr>
                    <td class="label">是否上架：</td>
                    <td>
                        <input type="radio" name="is_onsale" value="1"/> 是
                        <input type="radio" name="is_onsale" value="0"/> 否
                    </td>
                </tr>
                <tr>
                    <td class="label">商品LOGO：</td>
                    <td>
                        <input type="file" name="logo" size="60" />
                    </td>
                </tr>
            </table>
            <!--商品描述-->
            <table width="100%" style="display:none;" class="tab_table" align="center">
                <tr>
                    <td>
                        <textarea id="goods_desc" name="goods_desc" cols="40" rows="3"></textarea>
                    </td>
                </tr>
            </table>
            <!--会员价格-->
            <table width="90%" style="display:none;" class="tab_table" align="center">
                <tr>
                    <td>
                        <?php foreach ($mlData as $k => $v): ?>
                        <p>
                            <strong><?php echo $v['level_name']; ?></strong>
                            ￥<input type="text" name="member_ptice[<?php echo $v['id'];?>]" size="8" />元<br/>
                        </p>
                        <?php endforeach; ?>
                    </td>
                </tr>
            </table>
            <!--商品属性-->
            <table width="90%" style="display:none;" class="tab_table" align="center">
                <tr><td></td></tr>
            </table>
            <!--商品相册-->
            <table width="100%" style="display:none;" class="tab_table" align="center">
                <tr>
                    <td>
                        <input id="btn_add_pic" type="button" value="添加一张" />
                        <hr>
                        <ul id="ul_pic_list"></ul>
                        <hr>
                        <ul id="old_pic_list">
                            <?php foreach ($gpDate as $k => $v): ?>
                            <li>
                                <input pic_id="<?php echo $v['id']; ?>" class="btn_del_pic" type="button" value="删除" /><br>
                                <?php showImage($v['mid_pic'],150); ?>
                            </li>
                            <?php endforeach; ?>
                        </ul>
                    </td>
                </tr>
            </table>
            <div class="button-div">
                <input type="submit" value=" 确定 " class="button"/>
                <input type="reset" value=" 重置 " class="button" />
            </div>
        </form>
    </div>
</div>

<!--导入在线编辑器-->
<link href="__PUBLIC__/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="__PUBLIC__/umeditor/third-party/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/umeditor/third-party/template.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/umeditor/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/umeditor/umeditor.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/umeditor/lang/zh-cn/zh-cn.js"></script>
<script>
    UM.getEditor('goods_desc',{
       initialFrameWidth : "100%",
       initialFrameHeight : 350
    });
</script>

<script>
    //切换的代码
    $("#tabbar-div p span").click(function(){
        //点击的第几个按钮
        var i = $(this).index();
        // 先隐藏所有的table
        $(".tab_table").hide();
        //显示第i个table
        $(".tab_table").eq(i).show();
        //先取消原按钮的选中状态
        $(".tab_table").removeClass("tab_front").addClass("tab_back");
        //设置当前按钮选中
        $(this).removeClass("tab_back").addClass("tab_front");
    });
</script>

<script>
    $("#btn_add_pic").click(function(){
        var file = '<li><input type="file" name="pic[]" /></li>';
        $("#ul_pic_list").append(file);
    });
</script>

<script>
    $(".btn_del_pic").click(function(){
        if(confirm('确定要删除吗？'))
        {
            var li = $(this).parent();
            var pid = $(this).attr("pic_id");
            $.ajax({
                type : "GET",
                url : "<?php echo U('ajaxDelPic',FALSE); ?>/picid/"+pid,
                success : function(data)
                {
                    li.remove();
                }
            });
        }
    });
</script>